package com.example.helloworld.persistence;

import android.graphics.drawable.Drawable;

public class IconTextItem {

	private Drawable icon;
	private String[] data;
	private boolean selectable =	true;
	
	public IconTextItem(Drawable icon, String[] data) {
		this.icon =	icon;
		this.data =	data;
	}
	
	public IconTextItem(Drawable icon, String data01, String data02, String data03) {
		this.icon =	icon;
		this.data =	new String[3];
		data[0] =	data01;
		data[1] =	data02;
		data[2] =	data03;
	}
	
	public boolean isSelectable() {
		return selectable;
	}
	
	public void setSelectable(boolean selectable) {
		this.selectable =	selectable;
	}
	
	public String[] getData() {
		return data;
	}
	public String getData(int index) {
		if (data == null || index >= data.length) {
			return null;
		}
		
		return data[index];
	}
	
	public void setData(String[] data) {
		this.data =	data;
	}
	
	public void setIcon(Drawable icon) {
		this.icon =	icon;
	}
	
	public Drawable getIcon() {
		return icon;
	}
	
	public int compareTo(IconTextItem other) {
		if (data != null) {
			String[] otherData =	other.getData();
			
			if (data.length == otherData.length) {
				for (int i = 0; i < data.length; i++) {
					if (!data[i].equals(otherData[i])) {
						return -1;
					}
				}
			} else {
				return -1;
			}
		} else {
			throw new IllegalArgumentException();
		}
		
		return 0;
	}
}
